package top.dreamlove;

// import top.dreamlove.core.Single.Download;
import top.dreamlove.core.ThreadDown.Download;

import java.util.Scanner;

// volatile
public class Main {
    public static void main(String[] args) throws Exception {
        // 测试文件(100MB) http://speedtest.zju.edu.cn/100M
        // 测试文件(5MB) https://cloudreve.123916.xyz/f/PnHj/101523-27562-01.dmp
        // 测试文件(400kb) https://cloudreve.123916.xyz/f/grtO/unzipme.zip
        String url;
        // 判断用户是否在运行时输入了内容
        if (args == null || args.length == 0) {
            for (;;){
                Scanner scanner = new Scanner(System.in);
                System.out.print("请输入下载url地址:");
                url = scanner.next();
                if(url != null){
                    break;
                }
            }

        } else {
            // 运行时输入了参数
            url = args[0];
        }
        //单线程下
        // Download download = new Download();
        // download.download(url);
        System.out.println("下载的url = " + url);
        //多线程下载
        Download download = new Download();
        download.download(url);


    }
}